<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />
    <script type="text/javascript" src="../script/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/public.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <title>注册</title>
</head>
<body>
    <header>
        <div class="headtit">
            <div>
               <!--  <img src="../image/arwri.png" alt=""> -->
                <p>注册</p>
                <em class="denglu" onclick="login()">登录</em>
            </div>
        </div>
    </header>
    <section class="regit_body">
        <div class="userrg_info">
            <ul>
                <li>
                    <p><img src="../image/user_in.png" alt=""></p>
                    <input type="text" name="username" placeholder="请输入姓名">
                </li>
                <li class="h_selct">
                    <p><img src="../image/hous.png" alt=""></p>

                    <input class="clec_kes clec_kes1" type="text" name="branch_id" placeholder="请选择处室" data-id="" readonly value="" />

                    <!-- <div class="selct_dom">
                        <ul id="keshi">
                         
                        </ul>
                    </div> -->
                    <select class="keshi_select">
                       <!--  <option value="">请选择处室</option>
                        <option value="301">301111</option>
                        <option value="302">302222</option> -->
                    </select>
                    <script type="text/javascript">
                        //$(".clec_kes1").val($(".keshi_select").val());
                        $('.keshi_select').change(function(){
                            
                            var id = $(".keshi_select").attr('value');
                            var na = $('#'+id).text();
                            $(".clec_kes1").val(na);

                            $(".clec_kes1").attr("data-id",id);

                            
                        })
                          
                    </script>

                    <em class="xuanzke"><img src="../image/sell0_1.png" alt=""></em>
                </li>
                <li>
                    <p><img src="../image/teln.png" alt=""></p>
                    <input class="telnumb" type="text" name="mobile" placeholder="请输入手机号码" placeholder="请输入手机号">
                    <em class="clows_tel"><img src="../image/closqx_1.png" alt=""></em>
                </li>
                <li>
                    <p><img src="../image/paswd_in.png" alt=""></p>
                    <input type="password" name="password" placeholder="请输入密码">
                </li>
                <li>
                    <p><img src="../image/paswd_in.png" alt=""></p>
                    <input type="password" name="t_password" placeholder="再次输入密码">
                </li>
            </ul>
        </div>
        <div class="btn_lorr">

            <input type="button" onclick="regist()" value="提交">
        </div>
    </section>
</body>
<script>
    $(function () {

        $('.telnumb').on('keyup', function () {
            var that = $(this);
            var value = that.val();
            value = value.replace(/[^0-9]/ig, "");
            var arr = value.split('');
            if (arr.length >= 4) {
                arr.splice(3, 0, ' ');
            }
            if (arr.length >= 9) {
                arr.splice(8, 0, ' ');
            }
            value = arr.join('');
            that.val(value);
        });

        /*选择科室*/

        /*$(".selct_dom > ul > li").click(function () {
            var sohe = $(".selct_dom").css('display') =='none';
            if (sohe == false){

                $(this).siblings("li").removeClass("mosu_dw");
                $(this).addClass("mosu_dw");
                $(".selct_dom").slideUp(500);
                $(this).parents(".selct_dom").prev(".clec_kes1").val($(this).text());

                $(this).parents(".selct_dom").prev(".clec_kes1").attr("data-id",$(this).attr('data-id'));

                $(".userrg_info ul li em.xuanzke img").removeClass("tran_aa");
            }
        })*/
        $(document).on("click",".h_selct input",function () {

            var sohe = $(".selct_dom").css('display') =='none';

            if(sohe == true){

                $(".selct_dom").stop(true,true).slideDown(500);
                $(".userrg_info ul li em.xuanzke img").addClass("tran_aa");
            }else if (sohe == false) {

                $(".selct_dom").stop(true,true).slideUp(500);
                $(".userrg_info ul li em.xuanzke img").removeClass("tran_aa");
            }
        })
        $("body,html").click(function () {

            var sohe = $(".selct_dom").css('display') == 'none';
            if (sohe == false) {

                $(".selct_dom").slideUp(500);
                $(".userrg_info ul li em.xuanzke img").removeClass("tran_aa");
            }
        });

        /*删除已输入手机号码*/
        $(document).on("click",".clows_tel > img",function () {

            $(this).parents("em").prev("input.telnumb").val("");
        })
    })
</script>

<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();


    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        

       

        //科室
        api.ajax({
            url:webSiteUrl+'/App/Public/branch',
            method:'post',
            data:{
                
            }
        },function(ret ,err){
     
            // alert(JSON.stringify(ret));

            if (ret.code == 200) {
                var ks = ret.data;
                html="";
                for (var i=0 ; i<ks.length ; i++) {
                   html += '<option id="'+ks[i].id+'" value="'+ks[i].id+'">'+ks[i].title+'</option>';
                }
                $('.keshi_select').html('<option value="">请选择处室</option>'+html);
            }else{
                alert(ret.msg);
            }
        });
            

    }

    //登录跳转
    function login(){
        api.openWin({
            name:'loginName',
            url:'./login.html',
            pageParam:{

            }
        });
    }

    

    //注册
    function regist(){
        var did = api.deviceId;
        var username = $('input[name=username]').val();
        var branch_id = $('input[name="branch_id"]').attr('data-id');
        var mobile = $('input[name=mobile]').val();
        var password = $('input[name=password]').val();
        var t_password = $('input[name=t_password]').val();


        if(username == ''){
            api.alert({msg:'请输入姓名！'});return;
        }else if(branch_id == ''){
            api.alert({msg:'请选择科室！'});return;
        }else if(mobile == ''){
            api.alert({msg:'请输入手机号！'});return;
        }else if(password == ''){
            api.alert({msg:'请输入密码！'});return;
        }else if(t_password == ''){
            api.alert({msg:'再次确认密码！'});return;
        }
        var p = {username:username,branch_id:branch_id,mobile:mobile,password:password,t_password:t_password,did:did};
        // alert(JSON.stringify(p));
        // return;
        api.ajax({
            url: webSiteUrl + '/App/Public/resgin',
            method:'post',
            dataType: "json",
            data:{
                values:p,
            }
        },function(ret,err){

              // alert(JSON.stringify(ret));

            if (ret.code == 200) {
                
                api.openWin({
                    name: 'zhucetjName',
                    url: './zhucetj.html',
                    pageParam: {
                        name: 'text'
                    }
                });
            }else{
                alert(ret.msg)
            }
        });
    }
    
</script>
</html>